// component/add_work_info/add_work_info.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */

  data: {
    date: '请选择',
    datel: '请选择',
    array: ['大专', '本科', '研究生及以上'],
    index: 1,
    goods_info: {
      goods_rtime: '',
      goods_ltime: '',
      goods_name: '',
      goods_bumen: '',
      goods_infos: '',
      goods_edu: '',
    },
    goods_length: 0
  },

  methods: {
    //入职时间
    bindDateChange: function (e) {
      let goods_info = this.data.goods_info;
      goods_info.goods_rtime = e.detail.value;
      this.setData({
        goods_info,
        date: e.detail.value
      })
    },
    bindPickerChange(e) {
      let goods_info = this.data.goods_info;
      goods_info.goods_edu = this.data.array[e.detail.value];
      this.setData({
        goods_info,
        index: e.detail.value
      })
    },
    lbindDateChange: function (e) {
      let goods_info = this.data.goods_info;
      goods_info.goods_ltime = e.detail.value;
      console.log('picker发送选择改变，携带值为', e.detail.value)
      this.setData({
        goods_info,
        datel: e.detail.value
      })
    },
    change_goods_name(e) {
      let goods_info = this.data.goods_info;
      goods_info.goods_name = e.detail.value;
      this.setData({
        goods_info
      })
    },
    change_goods_zhiwei(e) {
      let goods_info = this.data.goods_info;
      goods_info.goods_zhiwei = e.detail.value;
      this.setData({
        goods_info
      })
    },
    change_goods_bumen(e) {
      let goods_info = this.data.goods_info;
      goods_info.goods_bumen = e.detail.value;
      this.setData({
        goods_info
      })
    },
    change_goods_infos(e) {
      let goods_info = this.data.goods_info;
      goods_info.goods_infos = e.detail.value;
      this.setData({
        goods_info
      })
    },
    save_goods() {
      // 货物表单组件保存数据时，先查询本地缓存中的 货物信息
      let goods_list = wx.getStorageSync("publish_edu_list");
      console.log(goods_list)
      goods_list.push(this.data.goods_info);
      wx.setStorageSync("publish_edu_list", goods_list);
      console.log("save succ")
      this.triggerEvent('savesucc', {}, {})
    },
    onMyEvent: function (e) {
      this.setData({
        show_alert: false
      })
    },
    start_save() {
      this.setData({
        show_alert: true
      })
    },
  },
  ready() {
    console.log("created");
    // 每次打开组件 都会触发的 方法
    // 在这个方法中 获取当前的货物信息
    let goods_list = wx.getStorageSync("publish_edu_list");
    console.log(goods_list)
    this.setData({
      goods_length: goods_list.length + 1
    })
  }

})